package mesh

import "strings"

// Type is mesh type
type Type string

const (
	// Unknown unknown mesh type
	Unknown Type = "unknown"
	// ThreeDs .3ds
	ThreeDs Type = "_3ds"
	// ThreeMf .3mf
	ThreeMf Type = "_3mf"
	// Amf .amf
	Amf Type = "amf"
	// Assimp .assimp
	Assimp Type = "assimp"
	// Awd .awd
	Awd Type = "awd"
	// Binary .binary
	Binary Type = "binary"
	// Babylon .babylon
	Babylon Type = "babylon"
	// Babylonmeshdata .babylonmeshdata
	Babylonmeshdata Type = "babylonmeshdata"
	// Bvh .bvh
	Bvh Type = "bvh"
	// Ctm .ctm
	Ctm Type = "ctm"
	// Dae .dae
	Dae Type = "dae"
	// Drc .drc
	Drc Type = "drc"
	// Fbx .fbx
	Fbx Type = "fbx"
	// Gcode .gcode
	Gcode Type = "gcode"
	// Glb .glb
	Glb Type = "glb"
	// Gltf .gltf
	Gltf Type = "gltf"
	// Js .js
	Js Type = "js"
	// JSON .json
	JSON Type = "json"
	// ThreeGeo .3geo
	ThreeGeo Type = "_3geo"
	// ThreeMat .3mat
	ThreeMat Type = "_3mat"
	// ThreeObj .3obj
	ThreeObj Type = "_3obj"
	// ThreeScn .3scn
	ThreeScn Type = "_3scn"
	// Kmz .kmz
	Kmz Type = "kmz"
	// Md2 .md2
	Md2 Type = "md2"
	// Nrrd .nrrd
	Nrrd Type = "nrrd"
	// Obj .obj
	Obj Type = "obj"
	// Pcd .pcd
	Pcd Type = "pcd"
	// Pdb .pdb
	Pdb Type = "pdb"
	// Playcanvas .playcanvas
	Playcanvas Type = "playcanvas"
	// Ply .ply
	Ply Type = "ply"
	// Pmd .pmd
	Pmd Type = "pmd"
	// Pmx .pmx
	Pmx Type = "pmx"
	// Prwm .prwm
	Prwm Type = "prwm"
	// Sea3d .sea3d
	Sea3d Type = "sea3d"
	// Stl .stl
	Stl Type = "stl"
	// Vrm .vrm
	Vrm Type = "vrm"
	// Vrml .vrml
	Vrml Type = "vrml"
	// Vtk .vtk
	Vtk Type = "vtk"
	// Wrl .wrl
	Wrl Type = "wrl"
	// Lol .lmesh
	Lol Type = "lol"
	// X .x
	X Type = "x"
	//Geo.geo
	Geo Type = "geo"
	// Qgis Qgis.qgis
	Qgis Type = "qgis"
	// Qgis2_3 Qgis.qgis
	Qgis2_3 Type = "qgis2.3"
	// Qgis2_5 Qgis.qgis
	Qgis2_5 Type = "qgis2.5"
	// Cgs .cgs
	Cgs Type = "cgs"
	// Ts .ts gocad 模型
	Ts Type = "ts"
	// Dxf .dxf 模型
	Dxf Type = "dxf"
)

// map
const (
	// Qgis2Web qgis 导入的 mapbox 类型数据
	Qgis2Web Type = "qgis2web"
)

var typeMap = map[string]Type{
	"3ds":      ThreeDs,
	"3mf":      ThreeMf,
	"amf":      Amf,
	"assimp":   Assimp,
	"bin":      Binary,
	"json":     JSON,
	"js":       Js,
	"awd":      Awd,
	"babylon":  Babylon,
	"bvh":      Bvh,
	"ctm":      Ctm,
	"dae":      Dae,
	"drc":      Drc,
	"fbx":      Fbx,
	"gcode":    Gcode,
	"glb":      Glb,
	"gltf":     Gltf,
	"geo":      Geo,
	"qgis":     Qgis,
	"qgis2_3":  Qgis2_3,
	"qgis2_5":  Qgis2_5,
	"kmz":      Kmz,
	"md2":      Md2,
	"nrrd":     Nrrd,
	"obj":      Obj,
	"pcd":      Pcd,
	"pdb":      Pdb,
	"ply":      Ply,
	"pmd":      Pmd,
	"pmx":      Pmx,
	"prwm":     Prwm,
	"sea":      Sea3d,
	"stl":      Stl,
	"vrm":      Vrm,
	"vtk":      Vtk,
	"cgs":      Cgs,
	"ts":       Ts,
	"dxf":      Dxf,
	"x":        X,
	"qgis2web": Qgis2Web,
	"lmesh":    Lol,
}

// GetType 根据文件后缀获取文件类型
func GetType(typ string) Type {
	typ = strings.ReplaceAll(typ, ".", "")
	if t, ok := typeMap[typ]; ok {
		return t
	}

	return Unknown
}
